# Maintainer: Laurent Carlier <lordheavym@gmail.com>

pkgbase=vulkan-docs
pkgname=(vulkan-html-docs)
pkgver=1.3.257
pkgrel=1
epoch=1
_pkgname=Vulkan-Docs
arch=(any)
url="https://www.khronos.org/vulkan/"
license=('custom')
makedepends=(python3 python-pyparsing dblatex source-highlight cmake ghostscript nodejs npm git)
makedepends+=(rubygems graphicsmagick pango gdk-pixbuf2 jbigkit)
groups=(vulkan-devel)
source=("https://github.com/KhronosGroup/${_pkgname}/archive/v${pkgver}.tar.gz")
sha256sums=('4c0a0607d57db783534abf556c26a14944e3c3a06e4ca8d35bc87d7ecc8e9686')

prepare() {
  export PATH="${PATH}:/build/.local/share/gem/ruby/3.0.0/bin"

  gem install -N asciidoctor:1.5.8 asciidoctor-diagram asciidoctor-mathematical \
     asciidoctor-pdf coderay json-schema i18n prawn-gmagick \
     pygments.rb rouge text-hyphen

  npm install escape-string-regexp@2.0.0 he lunr@2.3.6
}

build() {
  export PATH="${PATH}:/build/.local/share/gem/ruby/3.0.0/bin"
  export NODE_PATH="${srcdir}/node_modules"

  cd "${srcdir}/${_pkgname}-${pkgver}"

  ./makeAllExts html chunked manhtmlpages styleguide registry
}

package_vulkan-html-docs() {
  pkgdesc="Vulkan html documentation"
  cd "${_pkgname}-${pkgver}"

  install -dm755 "${pkgdir}/usr/share/doc/vulkan"
  install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}"

  mv -v gen/out/man "${pkgdir}/usr/share/doc/vulkan/"
  mv -v gen/out/html/* "${pkgdir}/usr/share/doc/vulkan/"
  mv -v gen/out/registry.html "${pkgdir}/usr/share/doc/vulkan/"
  mv -v gen/out/styleguide.html "${pkgdir}/usr/share/doc/vulkan/"

  install -m644 LICENSE.adoc ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
}
